import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router-deprecated';
import { BaseRequestOptions,Http,Response, HTTP_PROVIDERS,Headers,URLSearchParams} from '@angular/http';
import {ProjService} from '../services/proj.service';
import {Proj} from '../model/proj.model';


@Component({
  selector: 'showProj-component',
  viewProviders: [HTTP_PROVIDERS,ProjService],
  templateUrl: 'app/proj/tpl/show-projs.component.html'
})
export class ShowProjsComponent implements OnInit {

  projs:Proj[];
  router:Router;
  constructor(private projService:ProjService,router:Router) {
    this.router = router;
    this.projService.authInit(router,()=>{})
  }

  ngOnInit() {
    if(this.projService.getMyProjs())
    {
      this.projService.getMyProjs().subscribe(data=>{
        this.projs = data.json();
      });
    }

  }

  edit(id,index)
  {
    var p = this.projs[index];
    this.router.navigate( ['EditProj',{id:id}]);
  }

  show(id,index)
  {
    var p = this.projs[index];
    this.router.navigate( ['Group',{projId:id}]);
  }

  formateDate(date)
  {
    var d = new Date(date);
    return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  }

}

/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
